<#assign filePath>${project.projectName}/${project.projectName}-biz/src/main/java/${project.basePackage?replace(".","/")}/${model.moduleName?replace(".","/")}/model/</#assign>
<#assign fileName>${model.name?cap_first}.java</#assign>
<#if model.type!="ENTITY"><#stop></#if>
package ${project.basePackage}.${model.moduleName}.model;

<#assign importPkgs=['lombok.Data','io.swagger.v3.oas.annotations.media.Schema','com.fa4j.common.data.model.Base']>
<#list model.fieldList?filter(f->!(["deleted","createTime","updateTime"]?seq_contains(f.name))) as field>
    <#if field.type=='OBJECT'>
        <#assign packageName=project.basePackage+"."+models[field.modelId?string].moduleName+".model."+models[field.modelId?string].name?cap_first>
    <#else>
        <#assign packageName=field.type.type.name>
    </#if>
    <#if !packageName?starts_with("java.lang") && !packageName?starts_with(project.basePackage+"."+model.moduleName+".model") && !importPkgs?seq_contains(packageName) >
        <#assign importPkgs=importPkgs+[packageName]>
    </#if>
    <#if field.isList?? && field.isList &&  !importPkgs?seq_contains("java.util.List")>
        <#assign importPkgs=importPkgs+["java.util.List"]>
    </#if>
    <#if model.tableName??>
        <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableName')>
            <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableName']>
        </#if>
        <#if model.primaryFieldId?? && model.primaryFieldId == field.id>
            <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableId','com.baomidou.mybatisplus.annotation.IdType']>
        <#elseif field.isList?? && field.isList>
            <#if field.type=='STRING'>
                <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableField')>
                    <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableField']>
                </#if>
                <#if !importPkgs?seq_contains('com.fa4j.common.data.repository.handler.StringListTypeHandler')>
                    <#assign importPkgs=importPkgs+['com.fa4j.common.data.repository.handler.StringListTypeHandler']>
                </#if>
            <#elseif field.type=='INTEGER'>
                <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableField')>
                    <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableField']>
                </#if>
                <#if !importPkgs?seq_contains('com.fa4j.common.data.repository.handler.IntegerListTypeHandler')>
                    <#assign importPkgs=importPkgs+['com.fa4j.common.data.repository.handler.IntegerListTypeHandler']>
                </#if>
            <#elseif field.type=='LONG'>
                <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableField')>
                    <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableField']>
                </#if>
                <#if !importPkgs?seq_contains('com.fa4j.common.data.repository.handler.LongListTypeHandler')>
                    <#assign importPkgs=importPkgs+['com.fa4j.common.data.repository.handler.LongListTypeHandler']>
                </#if>
            <#else>
                <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableField')>
                    <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableField']>
                </#if>
            </#if>
        <#elseif field.type=='OBJECT'>
            <#assign fieldModel=models[field.modelId?string] >
            <#if fieldModel.tableName?? && !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableField') >
                <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableField']>
            <#elseif fieldModel.type!="DICT">
                <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.annotation.TableField')>
                    <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.annotation.TableField']>
                </#if>
                <#if !importPkgs?seq_contains('com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler')>
                    <#assign importPkgs=importPkgs+['com.baomidou.mybatisplus.extension.handlers.Fastjson2TypeHandler']>
                </#if>
            </#if>
        </#if>
    </#if>
</#list>
<#list importPkgs?filter(p->!p?starts_with("java.lang"))?sort as pkg>
import ${pkg};
</#list>

/**
 * 实体-${model.remark}
 *
 * @since ${.now?string("yyyy-MM-dd HH:mm:ss")}
 */
@Data
<#if model.tableName??>
@TableName(value = "${model.tableName}", autoResultMap = true)
</#if>
@Schema(description = "${model.remark}")
public class ${model.name?cap_first} extends Base {

    <#list model.fieldList?filter(f->!(["deleted","createTime","updateTime"]?seq_contains(f.name))) as field>
        <#if field.type=='OBJECT'>
            <#assign fieldModel=models[field.modelId?string] >
            <#assign fieldType=fieldModel.name?cap_first >
        <#else >
            <#assign fieldType=field.type.type.simpleName >
        </#if>
        <#if model.tableName??>
            <#if model.primaryFieldId?? && model.primaryFieldId == field.id>
    @TableId(type = IdType.AUTO)
            <#elseif field.isList?? && field.isList>
                <#if field.type=='STRING'>
    @TableField(typeHandler = StringListTypeHandler.class)
                <#elseif field.type=='INTEGER'>
    @TableField(typeHandler = IntegerListTypeHandler.class)
                <#elseif field.type=='LONG'>
    @TableField(typeHandler = LongListTypeHandler.class)
                <#else>
    @TableField(exist=false)
                </#if>
            <#elseif field.type=='OBJECT'>
                <#assign fieldModel=models[field.modelId?string] >
                <#if fieldModel.tableName??>
    @TableField(exist=false)
                <#elseif fieldModel.type!="DICT">
    @TableField(typeHandler = Fastjson2TypeHandler.class)
                </#if>
            </#if>
        </#if>
    @Schema(description = "${field.remark}")
    <#if field.isList?? && field.isList>
    private List<${fieldType}> ${field.name};
    <#else>
    private ${fieldType} ${field.name};
    </#if>

    </#list>
}
